const Tag = require('../schema/tag.js').Tag;




const findnormal = (data) => {
    return new Promise((resolve, reject) => {
        Tag.find(data,(err, doc) => {
            if (err) {
                reject(err)
            }
            resolve(doc)
        })
    })
}


const insertone = function (data) {
    return new Promise((resolve, reject) => {
        Tag.create(data, (err) => {
            if (err) {
                reject(err)
            }
            resolve()
        })
    })
}
const dellist = function (id) {
    return new Promise((resolve, reject) => {
        Tag.findOneAndRemove(id, err => {
            if (err) {
                reject(err);
            }
         
            resolve();
        });
    });
};

const doedit = function (id, newdata) {
    return new Promise((resolve, reject) => {


        Tag.update(id, newdata, err => {
            if (err) {
                reject(err);
            }
            
            resolve();
        })
    })
}



module.exports = {
 
    findnormal,
    insertone,
    dellist,
    doedit,
 
  
}